export default {
  data() {
    return {}
  },
  mounted() {
    window.addEventListener('wheel', this.handleMouseWheel, {
      passive: false,
    })
  },
  beforeDestroy() {
    window.removeEventListener('wheel', this.handleMouseWheel, {
      passive: false,
    })
  },
  methods: {
    //滚动翻页
    handleMouseWheel(e) {
      if (!window.scrollY) {
        // 禁止页面滚动
        e.preventDefault()
        if (e.wheelDelta) {
          // 判断浏览器IE，谷歌滑轮事件
          if (e.wheelDelta > 0) {
            // 当滑轮向上滚动时
            this.jumpTo(this.index - 2)
          }
          if (e.wheelDelta < 0) {
            // 当滑轮向下滚动时
            this.jumpTo(this.index + 2)
          }
        } else if (e.detail) {
          // Firefox滑轮事件
          if (e.detail > 0) {
            // 当滑轮向下滚动时
            console.log(3)
            this.jumpTo(this.index + 2)
          }
          if (e.detail < 0) {
            // 当滑轮向上滚动时
            console.log(4)
            this.jumpTo(this.index - 2)
          }
        }
      }
    },
  },
}
